package top.leinx.fxnotes.font;

/**
 * @Author : xiaolei
 * @DateTime: 2021/3/22 5:10 下午
 */

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;

import java.util.List;

public class FontExample extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        List<String> fontFamilies = Font.getFamilies(); // 获取已经安装的字体系列

        for (String fontFamily : fontFamilies) {
            System.out.println(fontFamily);
            List<String> fontNames = Font.getFontNames(fontFamily); // 获取某个系列中安装的字体名称
            for (String fontName : fontNames) {
                System.out.println("\t" + fontName);
            }
        }

        Font font = Font.font("Arial", FontWeight.BLACK, FontPosture.ITALIC, 24.0);
        Text text = new Text("Welcome to JavaFX!");
        text.setFont(font);

        primaryStage.setTitle("Font 示例");
        primaryStage.setScene(new Scene(new StackPane(text), 400, 200));
        primaryStage.show();
    }
}
